package cn.cloud.butler.webapi.repository;

import cn.cloud.butler.webapi.domain.*;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by zhouguocheng on 2018-12-04-上午 8:30
 */
public interface RoleTRepository extends JpaRepository<RoleTEntity, Integer>{




    @Query(value = "SELECT * from RoleT WHERE  Role != '0' " ,nativeQuery = true)
    List<RoleTEntity> GetRole();
    @Query(value = "SELECT   " +
            "   *   " +
            "   FROM   " +
            "   RoleT,   " +
            "   Company    " +
            "   WHERE   " +
            "   RoleT.CompType = Company.CompType    " +
            "   AND Company.CompID = ?1 ",nativeQuery = true)
        List<RoleTEntity> getRoleTByCompType(Integer compid);


    @Query(value = "SELECT   " +
            "   *   " +
            "   FROM   " +
            "   RoleT,   " +
            "   Company    " +
            "   WHERE   " +
            "   RoleT.CompType = Company.CompType    " +
            "   AND Company.CompID = ?1 AND RoleType =0   ",nativeQuery = true)
    List<RoleTEntity> getRoleTByRoleType(Integer compId);


    @Query(value = "SELECT   " +
            "   *   " +
            "   FROM   " +
            "   RoleT,   " +
            "   Company    " +
            "   WHERE   " +
            "   RoleT.CompType = Company.CompType    " +
            "   AND Company.CompID = ?1 AND RoleType =1   ",nativeQuery = true)
    List<RoleTEntity> getRoleTByWeb(Integer compId);
}
